%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/unions-table/by-id-1"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 9, 68, 10<br />2: PgSelect[7]<br />3: PgSelectRows[12]<br />ᐳ: 11, 13, 14, 16, 17"):::bucket
    Bucket1("Bucket 1 (polymorphic)<br />__typename: Lambda[16]<br />Deps: 16, 10, 17"):::bucket
    Bucket2("Bucket 2 (polymorphicPartition)<br />|UnionTopic<br />Deps: 10, 17<br />ᐳUnionTopic<br /><br />1: PgSelect[19]<br />2: PgSelectRows[24]<br />ᐳ: 23, 25, 54, 59"):::bucket
    Bucket3("Bucket 3 (polymorphicPartition)<br />|UnionPost<br />Deps: 10, 17<br />ᐳUnionPost<br /><br />1: PgSelect[26]<br />2: PgSelectRows[31]<br />ᐳ: 30, 32, 55, 60, 64, 67"):::bucket
    Bucket4("Bucket 4 (polymorphicPartition)<br />|UnionDivider<br />Deps: 10, 17<br />ᐳUnionDivider<br /><br />1: PgSelect[33]<br />2: PgSelectRows[38]<br />ᐳ: 37, 39, 56, 61, 65"):::bucket
    Bucket5("Bucket 5 (polymorphicPartition)<br />|UnionChecklist<br />Deps: 10, 17<br />ᐳUnionChecklist<br /><br />1: PgSelect[40]<br />2: PgSelectRows[45]<br />ᐳ: 44, 46, 57, 62"):::bucket
    Bucket6("Bucket 6 (polymorphicPartition)<br />|UnionChecklistItem<br />Deps: 10, 17<br />ᐳUnionChecklistItem<br /><br />1: PgSelect[47]<br />2: PgSelectRows[52]<br />ᐳ: 51, 53, 58, 63, 66"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2 & Bucket3 & Bucket4 & Bucket5 & Bucket6

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸunion_itemsᐳ<br />More deps:<br />- Object[10]<br />- Constantᐸ1ᐳ[68]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 6"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    First11{{"First[11∈0] ➊"}}:::plan
    PgSelectRows12[["PgSelectRows[12∈0] ➊"]]:::plan
    PgSelectRows12 --> First11
    PgSelect7 --> PgSelectRows12
    PgSelectSingle13{{"PgSelectSingle[13∈0] ➊<br />ᐸunion_itemsᐳ"}}:::plan
    First11 --> PgSelectSingle13
    PgClassExpression14{{"PgClassExpression[14∈0] ➊<br />ᐸ__union_items__.”type”ᐳ"}}:::plan
    PgSelectSingle13 --> PgClassExpression14
    PgClassExpression17{{"PgClassExpression[17∈0] ➊<br />ᐸ__union_items__.”id”ᐳ"}}:::plan
    PgSelectSingle13 --> PgClassExpression17
    PgSelect19[["PgSelect[19∈2] ➊<br />ᐸunion_topicsᐳ<br />ᐳUnionTopic<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression17 --> PgSelect19
    First23{{"First[23∈2] ➊^"}}:::plan
    PgSelectRows24[["PgSelectRows[24∈2] ➊^"]]:::plan
    PgSelectRows24 --> First23
    PgSelect19 --> PgSelectRows24
    PgSelectSingle25{{"PgSelectSingle[25∈2] ➊^<br />ᐸunion_topicsᐳ"}}:::plan
    First23 --> PgSelectSingle25
    PgClassExpression54{{"PgClassExpression[54∈2] ➊^<br />ᐸ__union_topics__.”id”ᐳ"}}:::plan
    PgSelectSingle25 --> PgClassExpression54
    PgClassExpression59{{"PgClassExpression[59∈2] ➊^<br />ᐸ__union_to...__.”title”ᐳ"}}:::plan
    PgClassExpression54 o--o PgClassExpression59
    PgSelect26[["PgSelect[26∈3] ➊<br />ᐸunion_postsᐳ<br />ᐳUnionPost<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression17 --> PgSelect26
    First30{{"First[30∈3] ➊^"}}:::plan
    PgSelectRows31[["PgSelectRows[31∈3] ➊^"]]:::plan
    PgSelectRows31 --> First30
    PgSelect26 --> PgSelectRows31
    PgSelectSingle32{{"PgSelectSingle[32∈3] ➊^<br />ᐸunion_postsᐳ"}}:::plan
    First30 --> PgSelectSingle32
    PgClassExpression55{{"PgClassExpression[55∈3] ➊^<br />ᐸ__union_posts__.”id”ᐳ"}}:::plan
    PgSelectSingle32 --> PgClassExpression55
    PgClassExpression60{{"PgClassExpression[60∈3] ➊^<br />ᐸ__union_posts__.”title”ᐳ"}}:::plan
    PgClassExpression55 o--o PgClassExpression60
    PgClassExpression64{{"PgClassExpression[64∈3] ➊^<br />ᐸ__union_po...scription”ᐳ"}}:::plan
    PgClassExpression60 o--o PgClassExpression64
    PgClassExpression67{{"PgClassExpression[67∈3] ➊^<br />ᐸ__union_posts__.”note”ᐳ"}}:::plan
    PgClassExpression64 o--o PgClassExpression67
    PgSelect33[["PgSelect[33∈4] ➊<br />ᐸunion_dividersᐳ<br />ᐳUnionDivider<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression17 --> PgSelect33
    First37{{"First[37∈4] ➊^"}}:::plan
    PgSelectRows38[["PgSelectRows[38∈4] ➊^"]]:::plan
    PgSelectRows38 --> First37
    PgSelect33 --> PgSelectRows38
    PgSelectSingle39{{"PgSelectSingle[39∈4] ➊^<br />ᐸunion_dividersᐳ"}}:::plan
    First37 --> PgSelectSingle39
    PgClassExpression56{{"PgClassExpression[56∈4] ➊^<br />ᐸ__union_dividers__.”id”ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression56
    PgClassExpression61{{"PgClassExpression[61∈4] ➊^<br />ᐸ__union_di...__.”title”ᐳ"}}:::plan
    PgClassExpression56 o--o PgClassExpression61
    PgClassExpression65{{"PgClassExpression[65∈4] ➊^<br />ᐸ__union_di...__.”color”ᐳ"}}:::plan
    PgClassExpression61 o--o PgClassExpression65
    PgSelect40[["PgSelect[40∈5] ➊<br />ᐸunion_checklistsᐳ<br />ᐳUnionChecklist<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression17 --> PgSelect40
    First44{{"First[44∈5] ➊^"}}:::plan
    PgSelectRows45[["PgSelectRows[45∈5] ➊^"]]:::plan
    PgSelectRows45 --> First44
    PgSelect40 --> PgSelectRows45
    PgSelectSingle46{{"PgSelectSingle[46∈5] ➊^<br />ᐸunion_checklistsᐳ"}}:::plan
    First44 --> PgSelectSingle46
    PgClassExpression57{{"PgClassExpression[57∈5] ➊^<br />ᐸ__union_ch...sts__.”id”ᐳ"}}:::plan
    PgSelectSingle46 --> PgClassExpression57
    PgClassExpression62{{"PgClassExpression[62∈5] ➊^<br />ᐸ__union_ch...__.”title”ᐳ"}}:::plan
    PgClassExpression57 o--o PgClassExpression62
    PgSelect47[["PgSelect[47∈6] ➊<br />ᐸunion_checklist_itemsᐳ<br />ᐳUnionChecklistItem<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression17 --> PgSelect47
    First51{{"First[51∈6] ➊^"}}:::plan
    PgSelectRows52[["PgSelectRows[52∈6] ➊^"]]:::plan
    PgSelectRows52 --> First51
    PgSelect47 --> PgSelectRows52
    PgSelectSingle53{{"PgSelectSingle[53∈6] ➊^<br />ᐸunion_checklist_itemsᐳ"}}:::plan
    First51 --> PgSelectSingle53
    PgClassExpression58{{"PgClassExpression[58∈6] ➊^<br />ᐸ__union_ch...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle53 --> PgClassExpression58
    PgClassExpression63{{"PgClassExpression[63∈6] ➊^<br />ᐸ__union_ch...scription”ᐳ"}}:::plan
    PgClassExpression58 o--o PgClassExpression63
    PgClassExpression66{{"PgClassExpression[66∈6] ➊^<br />ᐸ__union_ch...s__.”note”ᐳ"}}:::plan
    PgClassExpression63 o--o PgClassExpression66

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,First11,PgSelectRows12,PgSelectSingle13,PgClassExpression14,PgClassExpression17 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgSelect19,First23,PgSelectRows24,PgSelectSingle25,PgClassExpression54,PgClassExpression59 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgSelect26,First30,PgSelectRows31,PgSelectSingle32,PgClassExpression55,PgClassExpression60,PgClassExpression64,PgClassExpression67 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelect33,First37,PgSelectRows38,PgSelectSingle39,PgClassExpression56,PgClassExpression61,PgClassExpression65 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgSelect40,First44,PgSelectRows45,PgSelectSingle46,PgClassExpression57,PgClassExpression62 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgSelect47,First51,PgSelectRows52,PgSelectSingle53,PgClassExpression58,PgClassExpression63,PgClassExpression66 bucket6

